import { Component,OnInit } from '@angular/core';
// 引入Parse第三方库
import * as Parse from "parse"

//1  导入 封装好的 request 文件
import { list } from '../request';

(Parse as any).serverURL = "http://metapunk.cn:9999/parse"
Parse.initialize("dev")

@Component({
  selector: 'app-page-home',
  templateUrl: './page-home.component.html',
  styleUrls: ['./page-home.component.scss']
})
export class PageHomeComponent implements OnInit {

  priceSum: number = 0

  selectMap:any = {} // id:boolean
  addNumbers(event: any, item: any) {
    const checked = event.detail.checked
    let price = item.price
    if (checked) {
      this.selectMap[item.objectId] = true
      this.priceSum += price
    } else {
      this.selectMap[item.objectId] = false
      this.priceSum -= price
    }
  }



  tagList = ["热销",  "推荐",  "活动" , "其他"]
    dishesList:any=[]
    


    myList: any
    choiceMap: Array<any> = []
    ngOnInit():void{
        this.showSort("item.theID")
      }
    async showSort(item:any){

      // console.log(this.choiceMap)

      // 2 调用函数
      list("msd").then(res => {
        // console.log(res)
        this.myList = res

      }).catch(e => {

        console.log("error")

      })

      // console.log(item);
      // let query = new Parse.Query("msd")
      // query.equalTo("msd",item) // 参考：https://docs.parseplatform.org/js/guide/#basic-queries
     
      // let list = await query.find()
      // this.dishesList = list 
    }
}


